<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{$siteInfo['title']}-{$siteInfo['subtitle']}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="/themes/amaze/assets/css/amazeui.min.css">
</head>
<body>
{include file="common/header" /}
<div id="alert"></div>
<form class="am-form am-form-horizontal am-container">
    <div class="am-form-group">
        <label for="doc-ipt-3" class="col-sm-2 am-form-label">用户名/邮箱</label>
        <div class="col-sm-10">
            <input type="text" id="doc-ipt-3" placeholder="输入用户名">
        </div>
    </div>

    <div class="am-form-group">
        <label for="doc-ipt-pwd-2" class="col-sm-2 am-form-label">密码</label>
        <div class="col-sm-10">
            <input type="password" id="doc-ipt-pwd-2" placeholder="输入密码">
        </div>
    </div>

    <div class="am-form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" onclick="login()" class="am-btn am-btn-danger am-btn-block">登录</button>
        </div>
    </div>
</form>
{include file="common/footer" /}
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="/themes/amaze/assets/js/amazeui.min.js"></script>
<script src="/themes/amaze/assets/js/common.js"></script>
<script>
function login() {
    var username = $("#doc-ipt-3").val();
    var password = $("#doc-ipt-pwd-2").val();
    $.ajax({
        type:"POST",
        url:"/home/member/login",
        data:{
            user:username,
            password:password,
        },
        success:function (e) {
            if (e.code == 1){
               $("#alert").append('<div class="am-alert am-alert-success" data-am-alert>\n' +
                   '    <button type="button" class="am-close">&times;</button>\n' +
                   '    <p>'+e.msg+'</p>\n' +
                   '</div>')
                setTimeout(function () {
                    location.href = "/";
                },1500)
            }else {
                $("#alert").append('<div class="am-alert am-alert-danger" data-am-alert>\n' +
                    '    <button type="button" class="am-close">&times;</button>\n' +
                    '    <p>'+e.msg+'</p>\n' +
                    '</div>')

                setTimeout(function () {
                    $(".am-alert-danger").alert('close')
                },2000)
            }
        }
    })
}
</script>
</html>